package com.beiing.tianshuai.tianshuai.base;

import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;

import com.mic.etoast2.Toast;

import com.qmuiteam.qmui.util.QMUIStatusBarHelper;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by magikliu on 2017/7/6.
 */

public abstract class BaseActivity extends AppCompatActivity {

    protected Unbinder mUnbinder;
    protected Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        QMUIStatusBarHelper.setStatusBarLightMode(this);
        mUnbinder = ButterKnife.bind(this);
        mContext = this;
        init();
    }

    /**
     * 获取布局文件id
     *
     * @return 布局文件id
     */
    protected abstract int getLayoutId();

    /**
     * 初始化其他需要在onCreate方法中执行的程序
     */
    protected abstract void init();

    /**
     * 等同于 Toast.SHORT
     *
     * @param text 信息内容
     */
    public void showShortText(String text) {
        Toast.makeText(getApplicationContext(), text, 0).show();
    }

    /**
     * 等同于 Toast.LONG
     *
     * @param text 信息内容
     */
    public void showLongText(String text) {
        Toast.makeText(getApplicationContext(), text, 1).show();
    }
}
